<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Default controller.
 */
class Welcome_Controller extends Template_Controller 
{
	public function __construct()
	{
		parent::__construct();

		$this->template->menu = '';
	}
	
	public function index()
	{
		$event = new Calendar_Event_Model();
		$article = new Article_Model();
		$view = new View('welcome');
		$view->topevents = $event->orderby('id', 'desc')->limit(6)->find_all();
		$view->whatsnew = Database::instance()->query("SELECT articles.*, block_elements.url_link FROM articles JOIN block_elements ON block_elements.source_pk_id=articles.id WHERE block_elements.block_id=2 ORDER BY sort");

		$model = new Product_Model();
		
		$view->new_products = Database::instance()->query("SELECT products.* FROM products JOIN block_elements ON block_elements.source_pk_id=products.id WHERE block_elements.block_id=4 ORDER BY sort");
		$view->best_products = Database::instance()->query("SELECT products.* FROM products JOIN block_elements ON block_elements.source_pk_id=products.id WHERE block_elements.block_id=5 ORDER BY sort");
		
		$this->template->content = $view->render();
	}
}